package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.EmployeeBean;
import com.project.mapper.IEmployeeMapper;
import com.project.mapper.IProcessMapper;
import com.project.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class EmployeeServiceImpl implements IEmployeeService {
    @Autowired
    private IEmployeeMapper employeeMapper;
    @Autowired
    private IProcessMapper processMapper;

    @Override
    public void add(EmployeeBean em) {
        employeeMapper.add(em);
    }

    @Override
    public void update(int id, String status) {
        employeeMapper.update(id,status);
        processMapper.update(id, LocalDate.now().toString());
    }

    @Override
    public void updateInfo(int id, String phone, int money) {
        employeeMapper.updateInfo(id,phone,money);
    }

    @Override
    public EmployeeBean findById(int id) {
        return employeeMapper.findById(id);
    }

    @Override
    public PageInfo<EmployeeBean> findByItem(int pageNO, String name, String speciality, String status, String orderItem) {
        PageHelper.startPage(pageNO,PAGE_SIZE);
        PageInfo<EmployeeBean> info = PageInfo.of(employeeMapper.findByItem(name,speciality,status,orderItem));
        return info;
    }

    @Override
    public List<EmployeeBean> findOther(int proId, String name, String speciality) {
        return employeeMapper.findOther(proId,name,speciality);
    }

    @Override
    public EmployeeBean findByIdRunTime(int id) {
        return employeeMapper.findByIdRunTime(1);
    }
}
